﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using CodeFirstDomain.Model;
using Framework.Infrastructure.Context;

namespace CodeFirstDomain.ModelContext
{
    class CodeFirstContext : MSDbContext
    {
        public CodeFirstContext() : base("CodeFirstSample") { }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<User>()
                .ToTable("Users");

            modelBuilder.Entity<User>()
                .HasMany(u => u.MBlogs)
                .WithRequired(m => m.Author)
                .WillCascadeOnDelete(true);
         
        }
    }
}
